<?php  
$file_name = "";  
$pattern = "app/worktrace*.apk";        //下载文件存放目录    

foreach (glob($pattern) as $filename) {
	if( $file_name == "" )
		$file_name = $filename;
	else if( $file_name < $filename )
		$file_name = $filename;
}
//检查文件是否存在    
if (! file_exists ( $file_name )) {    
    echo "文件找不到";    
    exit ();    
} else {    
    //打开文件    
    $file = fopen ( $file_dir . $file_name, "r" );    
    //输入文件标签     
    Header ( "Content-type: application/octet-stream" );    
    Header ( "Accept-Ranges: bytes" );    
    Header ( "Content-Length: " . filesize ( $file_dir . $file_name ) );    
    Header ( "Content-Disposition: attachment; filename=" . basename($file_name) );    
    //输出文件内容     
    //读取文件内容并直接输出到浏览器    
    echo fread ( $file, filesize ( $file_dir . $file_name ) );    
    fclose ( $file );    
    exit ();    
}
?>  